from restful.api__.public__.info.atomic.PersonalInfo import PersonalInfo
from restful.api__.public__.info.atomic.PostAllLikes import PostAllLikes
from restful.api__.public__.info.atomic.UserName import UserName


def _PostsRank(posts):
    return [{
        'pid':i.id,
        'time':i.time,
        'title':i.title,
        'author': UserName().get(uid=i.uid)[0]['data']['username'],
        'likes':len(PostAllLikes().get(pid=i.id)[0]['data'])
    }for i in posts if i]